package com.gjm.product.api;

import com.gjm.product.model.ProductInfo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(name = "product-service", path = "/product")
public interface ProductServiceApi {

    @RequestMapping("/getProductInfoById")
    ProductInfo getProductInfoById(@RequestParam("productId") Integer productId);

    /**
     * 方法中有单个参数
     * @RequestParam 不能省略
     * @param id
     * @return
     */
    @RequestMapping("/method1")
    String method1(@RequestParam Integer id);

    /**
     * 传递多个参数
     * @param id
     * @param name
     * @return
     */
    @RequestMapping("/method2")
    String method2(@RequestParam("id") Integer id,
                          @RequestParam("name") String name);

    /**
     * 传递对象
     * @param productInfo
     * @return
     */
    @RequestMapping("/method3")
    String method3(@SpringQueryMap ProductInfo productInfo);

    /**
     * 传递 json
     * @param productInfo
     * @return
     */
    @RequestMapping("/method4")
    String method4(@RequestBody ProductInfo productInfo);
}
